WTL Controls
|
Back to the WTL Controls Home Page. |
A CMultiPaneStatusBarCtrl descendant with a child CProgressBarCtrl that can be embedded in a user-selected pane. Default configuration creates a status bar with three panes, with the progress bar embedded in the third. Default pane IDs are ID_DEFAULT_PANE (defined as 0), 1 and 2. More...
#include <StatusBarPlus.h>
Public Member Functions | |
CStatusBarPlus () noexcept | |
virtual | ~CStatusBarPlus () |
virtual BOOL | SubclassStatusBar (HWND hFrameWnd, UINT ProgressBarCtlID, UINT style_flags=0) |
SubclassStatusBar subclasses a pre-existing status bar and creates a default 3 panes with a progress bar embedded in the third. Override to customize/alter this behavior. More... | |
virtual void | UnSubclassStatusBar () |
Release the status bar and destroy the embedded progress bar control. More... | |
CProgressBarCtrl & | ProgressBar () |
Returns a reference to the embedded CProgressBarCtrl. More... | |
BOOL | SetPaneStyle (int pane_index, UINT flags) |
Valid style flags are 0 (sunken - no longer works on Win10), SBT_NOBORDERS, SBT_OWNERDRAW, SBT_POPOUT, SBT_RTLREADING and SBT_NOTABPARSING. Specify only one per pane; see the MSDN documentation for the SB_SETTEXT message for more detail. More... | |
void | SetProgressBarMargin (int margin) |
Defines the margin around the embedded CProgressBarCtrl, within the pane client area. Make sure not to make this value too big. More... | |
int | GetProgressBarMargin () const |
Default : 2. More... | |
void | SetProgressBarPane (int pane_index) |
Select the pane to contain the embedded CProgressBarCtrl. More... | |
int | GetProgressBarPane () const |
Default : 2. More... | |
Protected Attributes | |
CProgressBarCtrl | m_ProgressBar |
int | m_iProgressBarMargin |
int | m_iProgressBarPane |
A CMultiPaneStatusBarCtrl descendant with a child CProgressBarCtrl that can be embedded in a user-selected pane. Default configuration creates a status bar with three panes, with the progress bar embedded in the third. Default pane IDs are ID_DEFAULT_PANE (defined as 0), 1 and 2.
A typical setup snippet is shown below. It configures a 3-pane status bar with the center pane owner-drawn, uses UISetText to modify text in the right-most pane, while leaving the left pane with the default pane functionality. The sample also loads an icon into the right pane, and demonstrates a little trick with tab characters in the pane text - if the text is preceded by one tab, it'll be centered. If it's preceded by two tabs, it'll be right justified. Also note that modifying text with UISetText as demonstrated takes a couple of preliminary steps. First, the pane has to be added to the UpdateUI map. This is accomplished by including it in the map declarations in the client application's mainframe header file:
The first parameter is the index of the pane to be updated, NOT it's ID. (Although, in this case, the defaults are the same.) And second, the status bar itself has to be added to the update map with the UIAddStatusBar call, as shown below. Failure to do so will prevent the text from being modified. And finally, to actually execute any pending changes, UIUpdateStatusBar()
is called from the mainframe OnIdle handler.
Calling UnSubclassStatusBar
when disposing of the parent window (e.g; in the parent's WM_DESTROY handler) ensures orderly destruction of the embedded CProgressBarCtrl.
NOTE: This implementation plays a little fast and loose with the intended functionality of CStatusBar::SetPanes
. The pane IDs passed as an array of integers are meant to be the IDs of strings in the host app's embedded string table resource. The default behavior loads these strings and measures their extent, then sizes the panes as neccessary to accomodate these strings. I've used the integers 1 and 2 as pane IDs, in addition to the framework defined ID_DEFAULT_PANE, which is defined as 0. Unless the string table contains strings with symbols defined as 1 and 2, the attempt to load string resources with these IDs will fail. Failure is silent with no side effects - the panes are given a client width of 0, and nothing worse. Of course, should an app define strings with symbols defined as 1 or 2, the panes will have some non-zero initial size. Either way, they can be sized directly with CStatusBar::SetPaneWidth
.
Definition at line 76 of file StatusBarPlus.h.
|
noexcept |
Definition at line 21 of file StatusBarPlus.cpp.
|
virtual |
Definition at line 27 of file StatusBarPlus.cpp.
|
virtual |
SubclassStatusBar subclasses a pre-existing status bar and creates a default 3 panes with a progress bar embedded in the third. Override to customize/alter this behavior.
Optional style flags might include PBS_SMOOTH to create a smooth progress fill. (Truth be told, I don't think Win10 supports anything BUT PBS_SMOOTH. It'll work fine with it, but looks the same without it.)
hStatusBar | The handle to the basic status bar. |
ProgressBarCtlID | The control ID to assign to the progress bar. |
style_flags | Additional style flags to apply to the progress bar (e.g., PBS_SMOOTH). WS_CHILD and WS_VISIBLE are included by default. |
BOOL | /c TRUE if succesful. |
Definition at line 47 of file StatusBarPlus.cpp.
|
virtual |
Release the status bar and destroy the embedded progress bar control.
void |
Definition at line 92 of file StatusBarPlus.cpp.
CProgressBarCtrl & BIS_WTL_CONTROLS::CStatusBarPlus::ProgressBar | ( | ) |
Returns a reference to the embedded CProgressBarCtrl.
CProgressBarCtrl& |
Definition at line 105 of file StatusBarPlus.cpp.
BOOL BIS_WTL_CONTROLS::CStatusBarPlus::SetPaneStyle | ( | int | pane_index, |
UINT | flags | ||
) |
Valid style flags are 0 (sunken - no longer works on Win10), SBT_NOBORDERS, SBT_OWNERDRAW, SBT_POPOUT, SBT_RTLREADING and SBT_NOTABPARSING. Specify only one per pane; see the MSDN documentation for the SB_SETTEXT message for more detail.
Owner-drawn status bar panels reflect their WM_DRAWITEM messages to the parent frame window (the status bar itself). (No WM_MEASUREITEM messages are sent.) The DRAWITEMSTRUCT CtlID parameter will be set to the control ID associated with the status bar (default is ATL_IDW_STATUS_BAR), and the ItemID will be the pane ID (if the default SubclassStatusBar method is used, they'll be numbered 0~2).
pane_index | The 0-based index of the pane to modify. |
flags | The new style. |
BOOL | /c TRUE if succesful. |
Definition at line 127 of file StatusBarPlus.cpp.
void BIS_WTL_CONTROLS::CStatusBarPlus::SetProgressBarMargin | ( | int | margin | ) |
Defines the margin around the embedded CProgressBarCtrl, within the pane client area. Make sure not to make this value too big.
margin | The new margin around the progress bar. |
void |
Definition at line 168 of file StatusBarPlus.cpp.
int BIS_WTL_CONTROLS::CStatusBarPlus::GetProgressBarMargin | ( | ) | const |
Default : 2.
Returns the current margin between the embedded CProgressBarCtrl and the pane containing it.
int | The current progress bar margin. |
Definition at line 181 of file StatusBarPlus.cpp.
void BIS_WTL_CONTROLS::CStatusBarPlus::SetProgressBarPane | ( | int | pane_index | ) |
Select the pane to contain the embedded CProgressBarCtrl.
pane_index | The index of the pane which will contain the embedded CProgressBarCtrl. |
void |
Definition at line 197 of file StatusBarPlus.cpp.
int BIS_WTL_CONTROLS::CStatusBarPlus::GetProgressBarPane | ( | ) | const |
Default : 2.
Returns the current index of the pane containing the embedded CProgressBarCtrl.
int | The current pane index. |
Definition at line 210 of file StatusBarPlus.cpp.
|
protected |
Definition at line 106 of file StatusBarPlus.h.
|
protected |
Definition at line 107 of file StatusBarPlus.h.
|
protected |
Definition at line 108 of file StatusBarPlus.h.